package cn.maxwell.HysTrixFactory;

import cn.maxwell.FeiClient.UserFeiGinClient;
import cn.maxwell.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeiGinClient> {
    @Override
    public UserFeiGinClient create(Throwable throwable) {
        return new UserFeiGinClient() {
            @Override
            public User loadById(Long id) {
                User user = new User();
                user.setId(-1L);
                user.setName("服务不可达");
                user.setSex(-1);
                return user;
            }
        };
    }
}
